/**
 * Created by liubin on 2017/4/26.
 */


var DzpkTableUILayer = GameCCSBase.extend({

    panel_ready : null,

    Button_invite : null,
    Button_start : null,
    Button_disband : null,

    players : null,
    mPlayerPoss : null,
    mPlayerInfos : null,

    chipPoints : null,
    chipPotPoints : null,

    timeLeft : null,
    nowSeat : null,

    ImageHost : null,

    Text_totalPot : null,

    //网络延迟
    mKwxSysInfoWidget : null,
    Button_kick1 : null,
    Button_kick2 : null,
    Button_kick3 : null,
    Button_kick4 : null,

    //同ip提醒
    Image_ipwarring : null,

    ctor : function() {
        this._super();
        this.loadCocostudio("res/ccs/DzpkTableUI.json");

        this.nowSeat = -1;

        this.panel_ready = mo.seekWidgetByName(this.ccsNode, "Panel_ready");

        this.Button_invite = mo.seekWidgetByName(this.ccsNode, "Button_invite");
        this.Button_start = mo.seekWidgetByName(this.ccsNode, "Button_start");
        this.Button_disband = mo.seekWidgetByName(this.ccsNode, "Button_disband");

        this.ImageHost = mo.seekWidgetByName(this.ccsNode, "Image_host");
        this.Text_totalPot = mo.seekWidgetByName(this.ccsNode, "Text_totalPot");

        this.Text_totalPot.setVisible(false);

        this.Button_kick1 = mo.seekWidgetByName(this.ccsNode, "Button_kick1");
        this.Button_kick2 = mo.seekWidgetByName(this.ccsNode, "Button_kick2");
        this.Button_kick3 = mo.seekWidgetByName(this.ccsNode, "Button_kick3");
        this.Button_kick4 = mo.seekWidgetByName(this.ccsNode, "Button_kick4");
        this.Image_ipwarring = mo.seekWidgetByName(this.ccsNode, "Image_ipwarring");

        //牌型提示
        mo.seekWidgetByName(this.ccsNode, "Button_cardType").addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                mo.dzpkTable.mDzpkCardTypeTipLayer.setDialog(true);
            }
        }, this);

        //设置
        mo.seekWidgetByName(this.ccsNode, "Button_setting").addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                mo.dzpkTable.mDzpkTableSettingLayer.setDialog(true);
            }
        }, this);

        //规则
        mo.seekWidgetByName(this.ccsNode, "Button_rule").addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                mo.dzpkTable.addChild(new DzpkTableRuleLayer());
            }
        }, this);

        this.loadUI();

        // this.setCurrentPlayer(0);
    },

    onEnter : function () {
        this._super();
        this.schedule(this.updateClock);

        mo.eventHelper.add("UserOnLineChange", this, function(onlineInfo){
            this.setPlayerOnlineStats(onlineInfo);
        });

        mo.eventHelper.add("UserChatMsgResponse_reward", this, function(userChatMsgResponse){
            this.setChatMsgReward(userChatMsgResponse);
        });
    },

    onExit : function () {
        mo.eventHelper.remove(this);
        this._super();
        this.unschedule(this.updateClock);
    },


    loadUI : function () {

        //准备
        this.Button_start.addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                mo.gameMsgManager.sendGameReadyRequestdzpk();
            }
        }, this);

        //邀请
        this.Button_invite.addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                mo.dzpkTable.onInvite();
            }
        }, this);

        //退出
        this.Button_disband.addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                var isStart = mo.dzpkTable.mGameConfig.maxpan != mo.dzpkTableStatus.mTableStatus.LeftPlayTimes;
                if (!isStart){
                    mo.showMsgDialogOkAndCancel("确定退出房间吗？\n牌局未开始退出不会消耗房卡\n房主退出会解散牌桌", function(){
                        if (mo.dzpkTable.mGameConfig.maxpan == mo.dzpkTableStatus.mTableStatus.LeftPlayTimes){
                            mo.gameMsgManager.sendForceExitTableRequestdzpk();
                        }
                    }, this, function(){}, this);
                }
            }
        }, this);

        //踢人
        this.Button_kick1.addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                this.setKickPlayerForViewSeat(1);
            }
        }, this);

        this.Button_kick2.addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                this.setKickPlayerForViewSeat(2);
            }
        }, this);
        this.Button_kick3.addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                this.setKickPlayerForViewSeat(3);
            }
        }, this);

        this.Button_kick4.addTouchEventListener(function(sender, type){
            if (mo.gameHelper.getIsTouchEnd(type)) {
                this.setKickPlayerForViewSeat(4);
            }
        }, this);

        //players
        this.players = [];
        this.mPlayerPoss = [];

        for (var i=0; i<5; i++){
            var player = mo.seekWidgetByName(this.ccsNode, "player" + i);
            player.setTag(i);
            this.players.push(player);

            if (i == 0){
                this.mPlayerPoss.push(cc.pAdd(player.getPosition(), cc.p(0, 30)));
            }else{
                this.mPlayerPoss.push(cc.pAdd(player.getPosition(), cc.p(0, 30)));
            }

            //按钮
            player.addTouchEventListener(function(sender, type){
                if (mo.gameHelper.getIsTouchEnd(type)) {
                    if (mo.dzpkTable.mPlayerType == 0){
                        return;
                    }
                    var index = sender.getTag();
                    var logicSeat = mo.dzpkTableStatus.getLogicForView(index, mo.dzpkTableStatus.mTableStatus.MySeat - 1) + 1;
                    var seatUser = mo.dzpkTableStatus.mTableStatus["SeatUser" + logicSeat];
                    if (seatUser != null){
                        mo.dzpkTable.mDzpkTablePlayerInfoLayer.showPlayerInfo(index, seatUser.user_info, mo.dzpkTable.mDzpkUILayer.mPlayerPoss[index], logicSeat - 1);
                    }
                }
            }, this);



            var pos = player.getPosition();
            mo.dzpkCardHelper.playerPoints.push(pos);

            var clock = mo.seekWidgetByName(player, "Panel_clock");

            var Sprite_clockBg = new cc.Sprite.create("res/ccs/dzpk/seatclock11.png");
            Sprite_clockBg.setColor(cc.color(65, 244, 11));
            var progressTimer = new cc.ProgressTimer(Sprite_clockBg);
            progressTimer.setType(cc.ProgressTimer.TYPE_RADIAL);
            progressTimer.setPercentage(0);
            progressTimer.setTag(1);
            clock.addChild(progressTimer, -1);


            var Sprite_clockBar = new cc.Sprite.create("res/ccs/dzpk/seatclock.png");
            Sprite_clockBar.setColor(cc.color(53, 255, 0));
            var progressTimer1 = new cc.ProgressTimer(Sprite_clockBar);
            progressTimer1.setType(cc.ProgressTimer.TYPE_RADIAL);
            progressTimer1.setPercentage(0);
            progressTimer1.setTag(2);
            clock.addChild(progressTimer1, -1);


            var Particle_star = mo.seekWidgetByName(clock, "Particle_star");
            Particle_star.setTexture(cc.textureCache.addImage("res/ccs/dzpk/seatlight.png"));

            if (cc.sys.isNative){
                var Image_head = mo.seekWidgetByName(player, "Image_head");
                Image_head.setPosition(cc.p(0, 0));
                Image_head.removeFromParent();

                var clipper = new cc.ClippingNode();
                clipper.setInverted(false);
                clipper.setAlphaThreshold(0.5);

                var spirte = new cc.Sprite("res/ccs/dzpk/default.png");
                clipper.setStencil(spirte);

                clipper.addChild(Image_head);
                // mo.gameHelper.loadImageForUrl(Image_head, infos[i].user_info.faceUrl);
                // mo.gameHelper.loadImageForUrl(Image_head, "http://wx1.sinaimg.cn/mw690/891c9115ly1ffxdq56dhfj20hs0zk0tm.jpg");

                var size = player.getContentSize();
                clipper.setPosition(cc.p(size.width/2, size.height/2));

                player.addChild(clipper, -1);
            }
        }

        //发牌点
        var wellPoint = mo.seekWidgetByName(this.ccsNode, "Panel_cardsWellPos");
        mo.dzpkCardHelper.setWellPoint(wellPoint);

        //card pos
        for (var i=0; i<5; i++){
            var cardPos = mo.seekWidgetByName(this.ccsNode, "cardsPoint" + i);
            mo.dzpkCardHelper.cardInhandPoints.push(cardPos.getPosition());
        }

        //chipPoints
        this.chipPoints = [];
        for (var i=0; i<5; i++){
            var chipPos = mo.seekWidgetByName(this.ccsNode, "chipPoint" + i);
            mo.dzpkCardHelper.chipPoints.push(chipPos.getPosition());
            this.chipPoints.push(chipPos);
        }

        //chipPotPoints
        this.chipPotPoints = [];
        for (var i=0; i<5; i++){
            var chipPotPos = mo.seekWidgetByName(this.ccsNode, "potChipPoint" + i);
            mo.dzpkCardHelper.chipPotPoints.push(chipPotPos.getPosition());
            this.chipPotPoints.push(chipPotPos);
        }

        //wifi控件
        this.mKwxSysInfoWidget = new KwxSysInfoWidget();
        mo.seekWidgetByName(this.ccsNode, "Panel_wifi").addChild(this.mKwxSysInfoWidget);

    },

    reset : function () {
        for (var i=0; i<5; i++){
            this.setChipPotNum(i, 0);
            this.foldState(i, false);
            this.setCardTypeTextOfSeat(null, i);
        }

        this.setTotalPot(0);
    },

    //设置当前可操作的玩家
    setCurrentPlayer : function (seat) {
        this.nowSeat = seat;

        for (var i=0; i<5; i++){
            var player = this.players[i];
            var clock = mo.seekWidgetByName(player, "Panel_clock");
            if(i == seat){
                clock.setVisible(true);
                this.timeLeft = 0;

                var Particle_star = mo.seekWidgetByName(clock, "Particle_star");
                Particle_star.setVisible(true);

                var Image_gameLight = mo.seekWidgetByName(this.ccsNode, "Image_gameLight");
                Image_gameLight.setVisible(true);
                var pos1 = player.getPosition();
                var pos2 = Image_gameLight.getPosition();

                Image_gameLight.setScaleY(cc.pDistance(pos1, pos2) / 504);

                var deltaRotation = 90 - Math.atan2(pos2.y-pos1.y,pos2.x-pos1.x)*180/Math.PI;
                Image_gameLight.runAction(cc.rotateTo(0.2, deltaRotation));
            }else{
                clock.setVisible(false);
            }
        }
    },

    //当前玩家倒计时
    updateClock : function (dt) {
        if(this.nowSeat < 0 || this.nowSeat > 4){
            return;
        }

        this.timeLeft += dt;
        if(this.timeLeft >= 10.0){
            this.timeLeft = 10.0;
        }

        var player = this.players[this.nowSeat];
        if(player == undefined){
            return;
        }
        var clock = mo.seekWidgetByName(player, "Panel_clock");

        var Sprite_clockBg = clock.getChildByTag(1);
        var Sprite_clockBar = clock.getChildByTag(2);

        var percent = this.timeLeft / 10.0 * 100;

        Sprite_clockBg.setPercentage(percent);
        Sprite_clockBar.setPercentage(percent);

        var Particle_star = mo.seekWidgetByName(clock, "Particle_star");
        var x = 60 * Math.cos(Math.PI/2 - this.timeLeft / 10.0 * Math.PI * 2);
        var y = 60 * Math.sin(Math.PI/2 - this.timeLeft / 10.0 * Math.PI * 2);
        Particle_star.setPosition(cc.p(x,y));

    },

    setTablePlayerInfos : function (infos) {

        var isSeatFull = true;
        this.mPlayerInfos = infos;

        for (var i = 0; i < 5; i++) {
            var player = this.players[i];
            if (infos[i]) {
                player.setVisible(true);

                //nick
                var Text_name = mo.seekWidgetByName(player, "Text_name");
                mo.gameHelper.setTextString(Text_name, mo.gameHelper.getUserNickFilter(infos[i].user_info.nickname));

                var Image_head = mo.seekWidgetByName(player, "Image_head");
                mo.gameHelper.loadImageForUrl(Image_head, infos[i].user_info.faceUrl);
                //head
                // if (mo.gameHelper.isRead){
                //     // Image_head.setVisible(false);
                //
                //     cc.log("palyer:" + player.getChildByTag(100));
                //     if(player.getChildByTag(100) == null){
                //         cc.log("i:" + i);
                //
                //         var Image_head = mo.seekWidgetByName(player, "Image_head");
                //         Image_head.setPosition(cc.p(0, 0));
                //         Image_head.removeFromParent();
                //         // var newImage_head = new ccui.ImageView();
                //         // newImage_head.loadTexture("res/ccs/dzpk/default.png");
                //         // newImage_head.setContentSize(cc.size(115,115));
                //         // mo.gameHelper.loadImageForUrl(newImage_head, infos[i].user_info.faceUrl);
                //         // var headSize = newImage_head.getContentSize();
                //         // newImage_head.setScale(115 / headSize.width, 115 / headSize.height);
                //
                //
                //         var clipper = new cc.ClippingNode();
                //         clipper.setInverted(false);
                //         clipper.setAlphaThreshold(0.5);
                //
                //         var spirte = new cc.Sprite("res/ccs/dzpk/default.png");
                //         clipper.setStencil(spirte);
                //
                //         clipper.addChild(Image_head);
                //         mo.gameHelper.loadImageForUrl(Image_head, infos[i].user_info.faceUrl);
                //         // mo.gameHelper.loadImageForUrl(Image_head, "http://wx1.sinaimg.cn/mw690/891c9115ly1ffxdq56dhfj20hs0zk0tm.jpg");
                //
                //         var size = player.getContentSize();
                //         clipper.setPosition(cc.p(size.width/2, size.height/2));
                //
                //         player.addChild(clipper, -1, 100);
                //     }
                // }

                //筹码
                var cm = infos[i].CM;

                var Text_score = mo.seekWidgetByName(player, "Text_chipNum");
                mo.gameHelper.setTextString(Text_score, "筹码:" + cm);

                //输赢
                var Score = infos[i].Score;
                this.setResultNum(i, Score);

                //是否庄家
                var isHost = infos[i].IsHost;
                var Image_hostPoint = mo.seekWidgetByName(this.ccsNode, "hostPoint" + i);
                if(isHost){
                    if(this.ImageHost.isVisible() == false){
                        this.ImageHost.setVisible(true);
                        this.ImageHost.setPosition(Image_hostPoint);
                    }else{
                        this.ImageHost.runAction(cc.moveTo(0.3, Image_hostPoint));
                    }
                }

                //准备状态
                var Image_ready = mo.seekWidgetByName(player, "Image_ready");
                if (mo.dzpkTableStatus.mTableStatus.Step == 0 && infos[i].State == 1){
                    Image_ready.setVisible(true);
                }else{
                    Image_ready.setVisible(false);
                }
            }else{
                player.setVisible(false);
                isSeatFull = false;
            }
        }
    },

    setTotalPot : function (num) {
        this.Text_totalPot.setVisible(num > 0);
        mo.gameHelper.setTextString(this.Text_totalPot, "底池：" + num);
    },

    setResultNum : function (seat, num) {
        var Text_resultNum = mo.seekWidgetByName(this.players[seat], "Text_resultNum");
        var numStr = num >= 0 ? "赢:" : "输:" ;
        numStr += Math.abs(num);

        mo.gameHelper.setTextString(Text_resultNum, numStr);
    },

    setBetChipNum : function (seat, num) {
        var Text_chipNum = mo.seekWidgetByName(this.chipPoints[seat], "Text_chipNum");
        Text_chipNum.setVisible(!(num == 0));
        mo.gameHelper.setTextString(Text_chipNum, num);
    },

    setChipPotNum : function (index, num) {
        this.chipPotPoints[index].setVisible(!(num == 0));
        var Text_chipNum = mo.seekWidgetByName(this.chipPotPoints[index], "Text_chipNum");
        Text_chipNum.setVisible(!(num == 0));
        mo.gameHelper.setTextString(Text_chipNum, num);
    },


    showActionTip : function (actionCode, seat, State) {

        var Image_seatTipBg = mo.seekWidgetByName(this.players[seat], "Image_seatTipBg");
        var Image_oprationType = mo.seekWidgetByName(Image_seatTipBg, "Image_oprationType");

        if(State == 0){
            actionCode = 4;
        }

        if(actionCode < 0 || actionCode > 5){
            Image_seatTipBg.setVisible(false);
            return;
        }

        Image_seatTipBg.setVisible(true);
        if (actionCode == 0){
            mo.gameHelper.loadTextureImage(Image_oprationType, "res/ccs/dzpk/playgame/userstatus_add.png");
        }if (actionCode == 1){
            mo.gameHelper.loadTextureImage(Image_oprationType, "res/ccs/dzpk/playgame/userstatus_follow.png");
        }if (actionCode == 2){
            mo.gameHelper.loadTextureImage(Image_oprationType, "res/ccs/dzpk/playgame/userstatus_add.png");
        }if (actionCode == 3){
            mo.gameHelper.loadTextureImage(Image_oprationType, "res/ccs/dzpk/playgame/userstatus_look.png");
        }if (actionCode == 4){
            mo.gameHelper.loadTextureImage(Image_oprationType, "res/ccs/dzpk/playgame/userstatus_giveup.png");
        }if (actionCode == 5){
            mo.gameHelper.loadTextureImage(Image_oprationType, "res/ccs/dzpk/playgame/game_all_in_font.png");
        }
    },

    foldState : function (seat, state) {

        if(seat == 0){
            mo.dzpkTable.mDzpkCardLayer.mCardss[seat].mCardMask.setVisible(state);
            mo.dzpkTable.mDzpkCardLayer.mCardss[seat+5].mCardMask.setVisible(state);
        }else{
            mo.dzpkTable.mDzpkCardLayer.mCardss[seat].setVisible(!state);
            mo.dzpkTable.mDzpkCardLayer.mCardss[seat+5].setVisible(!state);
        }

        mo.seekWidgetByName(this.players[seat], "Image_fold").setVisible(state);
        if(state){
            this.players[seat].runAction(cc.scaleTo(0.3, 0.7));
        }else{
            this.players[seat].runAction(cc.scaleTo(0.3, 0.8));
        }


    },

    setCardTypeText : function (cardTypes) {

        for (var seat=0; seat<5; seat++){
            var typeIndex = cardTypes[seat];
            if(typeIndex != null){
                this.setCardTypeTextOfSeat(typeIndex, seat);
            }
        }
    },

    setCardTypeTextOfSeat : function (cardTypeIndex, seat) {

        var Text_cardType = mo.seekWidgetByName(mo.seekWidgetByName(this.ccsNode, "cardsPoint" + seat), "Text_cardType");
        if(cardTypeIndex != null){

            var cardTypeStr = mo.dzpkCardHelper.getCardTypeCHS(cardTypeIndex);
            Text_cardType.setVisible(true);
            mo.gameHelper.setTextString(Text_cardType, cardTypeStr);
        }else{
            Text_cardType.setVisible(false);
        }
    },

    showReady : function(isShow){
        if(isShow == false){
            this.panel_ready.setVisible(false);
            return;
        }
        this.panel_ready.setVisible(true);

        //是否打了一局了
        var isPlay = mo.dzpkTableStatus.mTableStatus.LeftPlayTimes != mo.dzpkTable.mGameConfig.maxpan;
        this.Button_invite.setVisible(!isPlay);
        this.Button_disband.setVisible(!isPlay);

        //自己是否准备
        var myIsReady = mo.dzpkTableStatus.getMyIsReady();
        if (myIsReady){
            mo.dzpkTable.mDzpkTableEndLayer.setVisible(false);
        }

        //准备按钮显示
        if (!isPlay){
            //还没有开始
            if (mo.dzpkTableStatus.mTableStatus.StartGameSeat == mo.dzpkTableStatus.mTableStatus.MySeat){
                //自己是开房负责人
                this.Button_start.setVisible(true);
                this.Button_start.setEnabled(mo.dzpkTableStatus.getPlayerCount() >= 2);
                this.Button_invite.setPositionX(mo.gameSize.x * 0.3);
                this.Button_disband.setPositionX(mo.gameSize.x * 0.7);
            }else{
                this.Button_start.setVisible(false);
                this.Button_invite.setPositionX(mo.gameSize.x * 0.4);
                this.Button_disband.setPositionX(mo.gameSize.x * 0.6);
            }
        }else{
            //已经开始
            this.Button_start.setPositionX(mo.gameSize.x / 2);
            this.Button_start.setEnabled(true);
            if (isPlay){
                this.Button_start.setVisible(false);
            }else{
                this.Button_start.setVisible(!myIsReady);
            }
        }

        //准备按钮上面的文字
        if (!isPlay){
            this.Button_start.loadTextures("res/ccs/dzpk/btn/btn_zhunbei1.png", "res/ccs/dzpk/btn/btn_zhunbei2.png", "res/ccs/dzpk/btn/btn_zhunbei3.png");
        }else{
            this.Button_start.loadTextures("res/ccs/dzpk/btn/btn_jixu1.png", "res/ccs/dzpk/btn/btn_jixu2.png", "res/ccs/dzpk/btn/btn_zhunbei3.png");
        }

        //处理同ip显示问题
        var ipEquals = mo.dzpkTableStatus.getPlayerIpEqual();
        if (ipEquals.length > 0 && !isPlay){
            this.Image_ipwarring.setVisible(true);
            for (var i = 0; i < 5; i++){
                var Panel_ip = mo.seekWidgetByName(this.Image_ipwarring, "Panel_ip" + i);
                if (ipEquals.length > i){
                    Panel_ip.setVisible(true);
                    mo.gameHelper.setTextString(mo.seekWidgetByName(Panel_ip, "Text_ip_nick"), ipEquals[i].nick);
                    mo.gameHelper.setTextString(mo.seekWidgetByName(Panel_ip, "Text_ip_ip"), ipEquals[i].ip);
                }else {
                    Panel_ip.setVisible(false);
                }
            }
        }else{
            this.Image_ipwarring.setVisible(false);
        }

        //能否显示踢人
        if (mo.dzpkTableStatus.mTableStatus != null && mo.dzpkTable.mGameConfig != null){
            var isPlay = mo.dzpkTableStatus.mTableStatus.LeftPlayTimes != mo.dzpkTable.mGameConfig.maxpan;
            var funcShowKick = function(viewSeat){
                if (isPlay){
                    return false;
                }

                var logicSeat = mo.dzpkTableStatus.getLogicForView(viewSeat, mo.dzpkTableStatus.mTableStatus.MySeat - 1) + 1;
                return mo.dzpkTable.mIsRoomCreator && mo.dzpkTableStatus.mTableStatus["SeatUser" + logicSeat] != null;
            };

            this.Button_kick1.setVisible(funcShowKick(1));
            this.Button_kick2.setVisible(funcShowKick(2));
            this.Button_kick3.setVisible(funcShowKick(3));
            this.Button_kick4.setVisible(funcShowKick(4));
        }

    },

    //设置离线状态
    setPlayerOnlineStats : function(onlineInfo){
        //重置
        for (var i = 0; i < 5; i++) {
            var Image_player = this.players[i];
            mo.seekWidgetByName(Image_player, "Image_online").setVisible(false);
        }

        //设置状态
        if (this.mPlayerInfos != null){
            for (var i = 0; i < 5; i++) {
                if (this.mPlayerInfos[i] == null){
                    continue;
                }
                var Image_player = this.players[i];
                var uid = this.mPlayerInfos[i].user_info.userid;

                if (onlineInfo[uid.toString()] != undefined && onlineInfo[uid.toString()] == 0){
                    mo.seekWidgetByName(Image_player, "Image_online").setVisible(true);
                }
            }
        }
    },

    //设置录像隐藏
    setIsReplay : function(isReplay){
        mo.seekWidgetByName(this.ccsNode, "Button_setting").setVisible(!isReplay);
        mo.seekWidgetByName(this.ccsNode, "Button_chat").setVisible(!isReplay);
    },

    //踢人
    setKickPlayerForViewSeat : function(viewSeat){
        var logicSeat = mo.dzpkTableStatus.getLogicForView(viewSeat, mo.dzpkTableStatus.mTableStatus.MySeat - 1) + 1;
        var SeatUser = mo.dzpkTableStatus.mTableStatus["SeatUser" + logicSeat];
        if (SeatUser != null){
            mo.showMsgDialogOkAndCancel("确定要踢掉玩家[" + SeatUser.user_info.nickname + "]吗?", function(){
                mo.gameMsgManager.sendCreateUserKickOutRequestdzpk(SeatUser.user_info.userid);
            }, this, function(){}, this);
        }
    },

    //礼包
    setChatMsgReward : function(userChatMsg){
        var kwxRewardLayer = new KwxRewardLayer();
        this.addChild(kwxRewardLayer);
        var toPlayer = mo.dzpkTableStatus.getViewSeatForUid(userChatMsg.uid);
        kwxRewardLayer.startAction(userChatMsg.msg, this.mPlayerPoss[toPlayer], toPlayer);
    }

});